class EndScore {
  constructor (ctx) {
    this.ctx = ctx
    this.bgimg = new Image()
    this.bgimg.src = 'images/Common.png'
    this.init = {
      x: ctx.canvas.width / 2 - 111,
      y: ctx.canvas.height / 2 - 100,
      w: 222,
      h: 200
    }
  }
  EndInfo (score) {
    this.ctx.font = '24px 微软雅黑'
    this.ctx.fillStyle = 'white'
    let scoreinfo = '分数：' + score
    this.ctx.fillText('游戏结束', this.ctx.canvas.width / 2 - 48, this.init.y + 42)
    this.ctx.fillText(scoreinfo, this.ctx.canvas.width / 2 - 48, this.init.y + 97)
  }
  showEndScore (score) {
    this.ctx.drawImage(this.bgimg, 4, 4, 111, 100, this.init.x, this.init.y, this.init.w, this.init.h )
    this.EndInfo(score)
    this.drawButton()
  }
  drawButton () {
    this.ctx.drawImage(this.bgimg, 119, 6, 41, 24, this.ctx.canvas.width / 2 - 61.5, this.ctx.canvas.height / 2 + 10, 123, 48)
    this.ctx.beginPath()
    this.ctx.font = '16px 微软雅黑'
    this.ctx.fillText('再来一次', this.ctx.canvas.width / 2 - 32 , this.ctx.canvas.height / 2 + 42)
  }
}
export default EndScore